<template>
	<div class="school">
		<button @click="add">点我添加到local</button>
		<button @click="show">点我展示</button>
		<button @click="del">点我删除</button>
		<button @click="delAll">点我删全部</button>
	</div>
</template>

<script>
	export default {
		name: 'School',
		data() {
			return {
				person: {
					name: '周亮',
					age: 22,
					project: '前端'
				}
			}
		},
		methods: {
			add() {
				localStorage.setItem('person', JSON.stringify(this.person))
			},
			show() {
				const result = localStorage.getItem('person');
				console.log(JSON.parse(result));
			},
			del() {
				localStorage.removeItem('person')
			},
			delAll() {
				localStorage.clear()
			}
		}
	}
</script>

<style scoped>
	.school {
		background-color: skyblue;
		padding: 20px;
	}
</style>